#pragma once
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <istream>
#include <ostream>
namespace MySTL {
class Mystring {

public:
  // 默认构造函数
  Mystring();
  // 从c风格字符串创建
  Mystring(const char *cstr);
  // 拷贝构造函数
  Mystring(const Mystring &other);
  // 移动拷贝构造函数
  Mystring(Mystring &&other);

  // 析构函数
  ~Mystring();

  // 赋值运算符重载
  Mystring &operator=(const char *cstr);
  Mystring &operator=(const Mystring &other);
  Mystring &operator=(Mystring &&other);

  size_t size() const;

  size_t length() const;

  size_t capacity() const;
  // 下标访问
  char &operator[](size_t pos);

  const char &operator[](size_t pos) const;

  char &at(size_t pos);

  const char &at(size_t pos) const;

  void clear();

  bool empty() const;

  void resize(size_t n, char c = '\0');

  const char *c_str() const;

  Mystring &operator+=(const char *cstr);

  Mystring &operator+=(const Mystring &str);

  Mystring &operator+=(char c);

  void push_back(char ch);

  Mystring &append(const char *cstr);

  Mystring &append(const char *cstr, size_t len);

  Mystring &append(const Mystring &other);

  Mystring substr(size_t pos, size_t len) const;

  bool operator==(const Mystring &other) const;

  bool operator!=(const Mystring &other) const;

  bool operator<(const Mystring &other) const;

  bool operator>(const Mystring &other) const;

  bool operator<=(const Mystring &other) const;

  bool operator>=(const Mystring &other) const;

private:
  char *m_data_;
  size_t m_len;
  size_t m_cap;
};
} // namespace MySTL

// 辅助函数 输出流
std::ostream &operator<<(std::ostream &os, const MySTL::Mystring &str);
// 输入流
std::istream &operator>>(std::istream &is, MySTL::Mystring &str);